package cn.lycode.system.domain.dto.sysdict;

import cn.lycode.common.utils.SecurityUtils;
import cn.lycode.system.domain.entity.SysDict;
import lombok.Data;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.Date;


/**
 * 字典添加
 */
@Data
public class SysDictAddDTO {
    @NotNull(message = "sysDictTypeId不能为空")
    private Long sysDictTypeId;

    private String codeName; //字典名称
    private String alias; //字典别名

    @Min(1)
    @Max(999999)
    private Integer dictSort; //排序

    private String callbackShowStyle; //回显样式
    private String remark; //备注"


    public SysDict buildAddEntity(){
        SysDict sysDict = new SysDict();
        sysDict.setSysDictTypeId(sysDictTypeId);
        sysDict.setCodeName(codeName);
        sysDict.setAlias(alias);
        sysDict.setDictSort(dictSort);
        sysDict.setCallbackShowStyle(callbackShowStyle);
        sysDict.setRemark(remark);
        sysDict.setCreateBy(SecurityUtils.getLoginUsername());
        sysDict.setCreateTime(new Date());
        return sysDict;
    }
}
